<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>perlmodstyle - Perl module style guide - Perldoc Browser</title>
    <link rel="search" href="https://perldoc.perl.org/opensearch.xml" type="application/opensearchdescription+xml" title="Perldoc Browser">
    <link rel="canonical" href="https://perldoc.perl.org/perlmodstyle">
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.5.0/styles/stackoverflow-light.min.css" integrity="sha512-cG1IdFxqipi3gqLmksLtuk13C+hBa57a6zpWxMeoY3Q9O6ooFxq50DayCdm0QrDgZjMUn23z/0PMZlgft7Yp5Q==" crossorigin="anonymous" />
    <style>
      body {
        background: #f4f4f5;
        color: #020202;
      }
      .navbar-dark {
        background-image: -webkit-linear-gradient(top, #005f85 0, #002e49 100%);
        background-image: -o-linear-gradient(top, #005f85 0, #002e49 100%);
        background-image: linear-gradient(to bottom, #005f85 0, #002e49 100%);
        filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff005f85', endColorstr='#ff002e49', GradientType=0);
        background-repeat: repeat-x;
      }
      .navbar-dark .navbar-nav .nav-link,
      .navbar-dark .navbar-nav .nav-link:focus { color: #fff }
      .navbar-dark .navbar-nav .nav-link:hover { color: #ffef68 }
      #wrapperlicious {
        margin: 0 auto;
        font: 0.9em 'Helvetica Neue', Helvetica, sans-serif;
        font-weight: normal;
        line-height: 1.5em;
        margin: 0;
        padding: 0;
      }
      #wrapperlicious h1 { font-size: 1.5em }
      #wrapperlicious h2 { font-size: 1.3em }
      #wrapperlicious h3 { font-size: 1.1em }
      #wrapperlicious h4 { font-size: 0.9em }
      #wrapperlicious h1, #wrapperlicious h2, #wrapperlicious h3,
      #wrapperlicious h4, #wrapperlicious dt {
        color: #020202;
        margin-top: 1em;
        margin-bottom: 1em;
        position: relative;
        font-weight: bold;
      }
      #wrapperlicious a { color: inherit; text-decoration: underline }
      #wrapperlicious #toc { text-decoration: none }
      #wrapperlicious a:hover { color: #2a2a2a }
      #wrapperlicious a img { border: 0 }
      #wrapperlicious :not(pre) > code {
        color: inherit;
        background-color: rgba(0, 0, 0, 0.04);
        border-radius: 3px;
        font: 0.9em Consolas, Menlo, Monaco, monospace;
        padding: 0.3em;
      }
      #wrapperlicious dd {
        margin: 0;
        margin-left: 2em;
      }
      #wrapperlicious dt {
        color: #2a2a2a;
        font-weight: bold;
        margin-left: 0.9em;
      }
      #wrapperlicious p {
        margin-bottom: 1em;
        margin-top: 1em;
      }
      #wrapperlicious li > p {
        margin-bottom: 0;
        margin-top: 0;
      }
      #wrapperlicious pre {
        border: 1px solid #c1c1c1;
        border-radius: 3px;
        font: 100% Consolas, Menlo, Monaco, monospace;
        margin-bottom: 1em;
        margin-top: 1em;
      }
      #wrapperlicious pre > code {
        display: block;
        background-color: #f6f6f6;
        font: 0.9em Consolas, Menlo, Monaco, monospace;
        line-height: 1.5em;
        text-align: left;
        white-space: pre;
        padding: 1em;
      }
      #wrapperlicious dl, #wrapperlicious ol, #wrapperlicious ul {
        margin-bottom: 1em;
        margin-top: 1em;
      }
      #wrapperlicious ul {
        list-style-type: square;
      }
      #wrapperlicious ul ul {
        margin-bottom: 0px;
        margin-top: 0px;
      }
      #footer {
        font-size: 0.8em;
        padding-top: 0.5em;
        text-align: center;
      }
      #more {
        display: inline;
        font-size: 0.8em;
      }
      #perldocdiv {
        background-color: #fff;
        border: 1px solid #c1c1c1;
        border-bottom-left-radius: 5px;
        border-bottom-right-radius: 5px;
        margin-left: auto;
        margin-right: auto;
        padding: 3em;
        padding-top: 1em;
        max-width: 960px;
      }
      #moduleversion { float: right }
      #wrapperlicious .leading-notice {
        font-style: italic;
        padding-left: 1em;
        margin-top: 1em;
        margin-bottom: 1em;
      }
      #wrapperlicious .permalink {
        display: none;
        left: -0.75em;
        position: absolute;
        padding-right: 0.25em;
        text-decoration: none;
      }
      #wrapperlicious h1:hover .permalink, #wrapperlicious h2:hover .permalink,
      #wrapperlicious h3:hover .permalink, #wrapperlicious h4:hover .permalink,
      #wrapperlicious dt:hover .permalink {
        display: block;
      }
    </style>
    <!-- Global site tag (gtag.js) - Google Analytics -->
    <script async src="https://www.googletagmanager.com/gtag/js?id=G-KVNWBNT5FB"></script>
    <script>
      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());

      gtag('config', 'G-KVNWBNT5FB');
      gtag('config', 'UA-50555-3');
    </script>
  </head>
  <body>
    <nav class="navbar navbar-expand-md navbar-dark bg-dark justify-content-between">
  <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
  </button>
  <a class="navbar-brand" href="https://perldoc.perl.org/">Perldoc Browser</a>
  <div class="collapse navbar-collapse" id="navbarNav">
    <ul class="navbar-nav mr-auto">
      <li class="nav-item dropdown text-nowrap">
        <a class="nav-link dropdown-toggle" href="perlmodstyle.html#" id="dropdownlink-stable" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">5.35.0</a>
        <div class="dropdown-menu" aria-labelledby="dropdownlink-stable">
          <a class="dropdown-item" href="https://perldoc.perl.org/perlmodstyle">Latest</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.2/perlmodstyle">5.38.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.1/perlmodstyle">5.38.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.0/perlmodstyle">5.38.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.3/perlmodstyle">5.36.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.2/perlmodstyle">5.36.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.1/perlmodstyle">5.36.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.0/perlmodstyle">5.36.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.3/perlmodstyle">5.34.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.2/perlmodstyle">5.34.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.1/perlmodstyle">5.34.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.0/perlmodstyle">5.34.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.32.1/perlmodstyle">5.32.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.32.0/perlmodstyle">5.32.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.3/perlmodstyle">5.30.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.2/perlmodstyle">5.30.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.1/perlmodstyle">5.30.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.0/perlmodstyle">5.30.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.3/perlmodstyle">5.28.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.2/perlmodstyle">5.28.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.1/perlmodstyle">5.28.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.0/perlmodstyle">5.28.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.3/perlmodstyle">5.26.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.2/perlmodstyle">5.26.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.1/perlmodstyle">5.26.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.0/perlmodstyle">5.26.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.4/perlmodstyle">5.24.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.3/perlmodstyle">5.24.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.2/perlmodstyle">5.24.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.1/perlmodstyle">5.24.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.0/perlmodstyle">5.24.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.4/perlmodstyle">5.22.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.3/perlmodstyle">5.22.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.2/perlmodstyle">5.22.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.1/perlmodstyle">5.22.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.0/perlmodstyle">5.22.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.3/perlmodstyle">5.20.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.2/perlmodstyle">5.20.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.1/perlmodstyle">5.20.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.0/perlmodstyle">5.20.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.4/perlmodstyle">5.18.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.3/perlmodstyle">5.18.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.2/perlmodstyle">5.18.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.1/perlmodstyle">5.18.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.0/perlmodstyle">5.18.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.3/perlmodstyle">5.16.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.2/perlmodstyle">5.16.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.1/perlmodstyle">5.16.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.0/perlmodstyle">5.16.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.4/perlmodstyle">5.14.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.3/perlmodstyle">5.14.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.2/perlmodstyle">5.14.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.1/perlmodstyle">5.14.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.0/perlmodstyle">5.14.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.5/perlmodstyle">5.12.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.4/perlmodstyle">5.12.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.3/perlmodstyle">5.12.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.2/perlmodstyle">5.12.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.1/perlmodstyle">5.12.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.0/perlmodstyle">5.12.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.10.1/perlmodstyle">5.10.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.10.0/perlmodstyle">5.10.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.9/perlmodstyle">5.8.9</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.8/perlmodstyle">5.8.8</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.7/perlmodstyle">5.8.7</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.6/perlmodstyle">5.8.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.5/perlmodstyle">5.8.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.4/perlmodstyle">5.8.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.3/perlmodstyle">5.8.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.2/perlmodstyle">5.8.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.1/perlmodstyle">5.8.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.0/perlmodstyle">5.8.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.6.2/perlmodstyle">5.6.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.6.1/perlmodstyle">5.6.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.6.0/perlmodstyle">5.6.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_04/perlmodstyle">5.005_04</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_03/perlmodstyle">5.005_03</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_02/perlmodstyle">5.005_02</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_01/perlmodstyle">5.005_01</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005/perlmodstyle">5.005</a>
        </div>
      </li>
      <li class="nav-item dropdown text-nowrap">
        <a class="nav-link dropdown-toggle" href="perlmodstyle.html#" id="dropdownlink-dev" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Dev</a>
        <div class="dropdown-menu" aria-labelledby="dropdownlink-dev">
          <a class="dropdown-item" href="https://perldoc.perl.org/blead/perlmodstyle">blead</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.6/perlmodstyle">5.39.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.5/perlmodstyle">5.39.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.4/perlmodstyle">5.39.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.3/perlmodstyle">5.39.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.2/perlmodstyle">5.39.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.1/perlmodstyle">5.39.1</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.0-RC2/perlmodstyle">5.38.0-RC2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.0-RC1/perlmodstyle">5.38.0-RC1</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.11/perlmodstyle">5.37.11</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.10/perlmodstyle">5.37.10</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.9/perlmodstyle">5.37.9</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.8/perlmodstyle">5.37.8</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.7/perlmodstyle">5.37.7</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.6/perlmodstyle">5.37.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.5/perlmodstyle">5.37.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.4/perlmodstyle">5.37.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.3/perlmodstyle">5.37.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.2/perlmodstyle">5.37.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.1/perlmodstyle">5.37.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.0/perlmodstyle">5.37.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.11/perlmodstyle">5.35.11</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.10/perlmodstyle">5.35.10</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.9/perlmodstyle">5.35.9</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.8/perlmodstyle">5.35.8</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.7/perlmodstyle">5.35.7</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.6/perlmodstyle">5.35.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.5/perlmodstyle">5.35.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.4/perlmodstyle">5.35.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.3/perlmodstyle">5.35.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.2/perlmodstyle">5.35.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.1/perlmodstyle">5.35.1</a>
          <a class="dropdown-item active" href="perlmodstyle.html">5.35.0</a>
        </div>
      </li>
      <li class="nav-item dropdown text-nowrap">
        <a class="nav-link dropdown-toggle" href="perlmodstyle.html#" id="dropdownlink-nav" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Documentation</a>
        <div class="dropdown-menu" aria-labelledby="dropdownlink-nav">
          <a class="dropdown-item" href="perl.html">Perl</a>
          <a class="dropdown-item" href="perlintro.html">Intro</a>
          <a class="dropdown-item" href="perl.html#Tutorials">Tutorials</a>
          <a class="dropdown-item" href="perlfaq.html">FAQs</a>
          <a class="dropdown-item" href="perl.html#Reference-Manual">Reference</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="perlop.html">Operators</a>
          <a class="dropdown-item" href="functions.html">Functions</a>
          <a class="dropdown-item" href="variables.html">Variables</a>
          <a class="dropdown-item" href="modules.html">Modules</a>
          <a class="dropdown-item" href="perlutil.html">Utilities</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="perlcommunity.html">Community</a>
          <a class="dropdown-item" href="perlhist.html">History</a>
        </div>
      </li>
    </ul>
    <ul class="navbar-nav">
      <script>
        function set_expand (expand) {
          var perldocdiv = document.getElementById('perldocdiv');
          var width = window.getComputedStyle(perldocdiv).getPropertyValue('max-width');
          var expanded = (width == '' || width == 'none') ? true : false;
          if (expand === null) {
            expand = !expanded;
          }
          if ((expand && !expanded) || (!expand && expanded)) {
            perldocdiv.style.setProperty('max-width', expand ? 'none' : '960px');
            var button_classlist = document.getElementById('content-expand-button').classList;
            if (expand) {
              button_classlist.add('btn-light');
              button_classlist.remove('btn-outline-light');
            } else {
              button_classlist.add('btn-outline-light');
              button_classlist.remove('btn-light');
            }
          }
          return expand;
        }
        function toggle_expand () {
          var expand = set_expand(null);
          document.cookie = 'perldoc_expand=' + (expand ? 1 : 0) + '; path=/; expires=Tue, 19 Jan 2038 03:14:07 UTC';
        }
        function read_expand () {
          return document.cookie.split(';').some(function (item) { return item.indexOf('perldoc_expand=1') >= 0 });
        }
        if (document.readyState === 'loading') {
          document.addEventListener('DOMContentLoaded', function () {
            if (read_expand()) {
              set_expand(true);
            }
          });
        } else if (read_expand()) {
          set_expand(true);
        }
      </script>
      <button id="content-expand-button" type="button" class="btn btn-outline-light d-none d-lg-inline-block mr-2" onclick="toggle_expand()">Expand</button>
    <ul>
    <form class="form-inline" method="get" action="https://perldoc.perl.org/5.35.0/search">
      <input class="form-control mr-3" type="search" name="q" placeholder="Search" aria-label="Search">
    </form>
  </div>
</nav>

    <div id="wrapperlicious" class="container-fluid">
      <div id="perldocdiv">
        <div id="links">
          <a href="perlmodstyle.html">perlmodstyle</a>
          <div id="more">
            (<a href="perlmodstyle.txt">source</a>,
            <a href="https://metacpan.org/pod/perlmodstyle">CPAN</a>)
          </div>
        </div>
        <div class="leading-notice">
          You are viewing the version of this documentation from Perl 5.35.0.
            This is a development version of Perl.
        </div>
        <h1><a id="toc">CONTENTS</a></h1>
                  <ul>
              <li>
                <a class="text-decoration-none" href="perlmodstyle.html#NAME">NAME</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlmodstyle.html#INTRODUCTION">INTRODUCTION</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlmodstyle.html#QUICK-CHECKLIST">QUICK CHECKLIST</a>
                            <ul>
              <li>
                <a class="text-decoration-none" href="perlmodstyle.html#Before-you-start">Before you start</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlmodstyle.html#The-API">The API</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlmodstyle.html#Stability">Stability</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlmodstyle.html#Documentation">Documentation</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlmodstyle.html#Release-considerations">Release considerations</a>
              </li>
          </ul>

              </li>
              <li>
                <a class="text-decoration-none" href="perlmodstyle.html#BEFORE-YOU-START-WRITING-A-MODULE">BEFORE YOU START WRITING A MODULE</a>
                            <ul>
              <li>
                <a class="text-decoration-none" href="perlmodstyle.html#Has-it-been-done-before?">Has it been done before?</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlmodstyle.html#Do-one-thing-and-do-it-well">Do one thing and do it well</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlmodstyle.html#What&#39;s-in-a-name?">What&#39;s in a name?</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlmodstyle.html#Get-feedback-before-publishing">Get feedback before publishing</a>
              </li>
          </ul>

              </li>
              <li>
                <a class="text-decoration-none" href="perlmodstyle.html#DESIGNING-AND-WRITING-YOUR-MODULE">DESIGNING AND WRITING YOUR MODULE</a>
                            <ul>
              <li>
                <a class="text-decoration-none" href="perlmodstyle.html#To-OO-or-not-to-OO?">To OO or not to OO?</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlmodstyle.html#Designing-your-API">Designing your API</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlmodstyle.html#Strictness-and-warnings">Strictness and warnings</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlmodstyle.html#Backwards-compatibility">Backwards compatibility</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlmodstyle.html#Error-handling-and-messages">Error handling and messages</a>
              </li>
          </ul>

              </li>
              <li>
                <a class="text-decoration-none" href="perlmodstyle.html#DOCUMENTING-YOUR-MODULE">DOCUMENTING YOUR MODULE</a>
                            <ul>
              <li>
                <a class="text-decoration-none" href="perlmodstyle.html#POD">POD</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlmodstyle.html#README,-INSTALL,-release-notes,-changelogs">README, INSTALL, release notes, changelogs</a>
              </li>
          </ul>

              </li>
              <li>
                <a class="text-decoration-none" href="perlmodstyle.html#RELEASE-CONSIDERATIONS">RELEASE CONSIDERATIONS</a>
                            <ul>
              <li>
                <a class="text-decoration-none" href="perlmodstyle.html#Version-numbering">Version numbering</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlmodstyle.html#Pre-requisites">Pre-requisites</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlmodstyle.html#Testing">Testing</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlmodstyle.html#Packaging">Packaging</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlmodstyle.html#Licensing">Licensing</a>
              </li>
          </ul>

              </li>
              <li>
                <a class="text-decoration-none" href="perlmodstyle.html#COMMON-PITFALLS">COMMON PITFALLS</a>
                            <ul>
              <li>
                <a class="text-decoration-none" href="perlmodstyle.html#Reinventing-the-wheel">Reinventing the wheel</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlmodstyle.html#Trying-to-do-too-much">Trying to do too much</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlmodstyle.html#Inappropriate-documentation">Inappropriate documentation</a>
              </li>
          </ul>

              </li>
              <li>
                <a class="text-decoration-none" href="perlmodstyle.html#SEE-ALSO">SEE ALSO</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlmodstyle.html#AUTHOR">AUTHOR</a>
              </li>
          </ul>

      <h1 id="NAME"><a class="permalink" href="perlmodstyle.html#NAME">#</a>NAME</h1>

<p>perlmodstyle - Perl module style guide</p>

<h1 id="INTRODUCTION"><a class="permalink" href="perlmodstyle.html#INTRODUCTION">#</a>INTRODUCTION</h1>

<p>This document attempts to describe the Perl Community&#39;s &quot;best practice&quot; for writing Perl modules. It extends the recommendations found in <a href="perlstyle.html">perlstyle</a> , which should be considered required reading before reading this document.</p>

<p>While this document is intended to be useful to all module authors, it is particularly aimed at authors who wish to publish their modules on CPAN.</p>

<p>The focus is on elements of style which are visible to the users of a module, rather than those parts which are only seen by the module&#39;s developers. However, many of the guidelines presented in this document can be extrapolated and applied successfully to a module&#39;s internals.</p>

<p>This document differs from <a href="perlnewmod.html">perlnewmod</a> in that it is a style guide rather than a tutorial on creating CPAN modules. It provides a checklist against which modules can be compared to determine whether they conform to best practice, without necessarily describing in detail how to achieve this.</p>

<p>All the advice contained in this document has been gleaned from extensive conversations with experienced CPAN authors and users. Every piece of advice given here is the result of previous mistakes. This information is here to help you avoid the same mistakes and the extra work that would inevitably be required to fix them.</p>

<p>The first section of this document provides an itemized checklist; subsequent sections provide a more detailed discussion of the items on the list. The final section, &quot;Common Pitfalls&quot;, describes some of the most popular mistakes made by CPAN authors.</p>

<h1 id="QUICK-CHECKLIST"><a class="permalink" href="perlmodstyle.html#QUICK-CHECKLIST">#</a><a id="QUICK"></a>QUICK CHECKLIST</h1>

<p>For more detail on each item in this checklist, see below.</p>

<h2 id="Before-you-start"><a class="permalink" href="perlmodstyle.html#Before-you-start">#</a><a id="Before"></a>Before you start</h2>

<ul>

<li><p>Don&#39;t re-invent the wheel</p>

</li>
<li><p>Patch, extend or subclass an existing module where possible</p>

</li>
<li><p>Do one thing and do it well</p>

</li>
<li><p>Choose an appropriate name</p>

</li>
<li><p>Get feedback before publishing</p>

</li>
</ul>

<h2 id="The-API"><a class="permalink" href="perlmodstyle.html#The-API">#</a><a id="The"></a>The API</h2>

<ul>

<li><p>API should be understandable by the average programmer</p>

</li>
<li><p>Simple methods for simple tasks</p>

</li>
<li><p>Separate functionality from output</p>

</li>
<li><p>Consistent naming of subroutines or methods</p>

</li>
<li><p>Use named parameters (a hash or hashref) when there are more than two parameters</p>

</li>
</ul>

<h2 id="Stability"><a class="permalink" href="perlmodstyle.html#Stability">#</a>Stability</h2>

<ul>

<li><p>Ensure your module works under <code>use strict</code> and <code>-w</code></p>

</li>
<li><p>Stable modules should maintain backwards compatibility</p>

</li>
</ul>

<h2 id="Documentation"><a class="permalink" href="perlmodstyle.html#Documentation">#</a>Documentation</h2>

<ul>

<li><p>Write documentation in POD</p>

</li>
<li><p>Document purpose, scope and target applications</p>

</li>
<li><p>Document each publicly accessible method or subroutine, including params and return values</p>

</li>
<li><p>Give examples of use in your documentation</p>

</li>
<li><p>Provide a README file and perhaps also release notes, changelog, etc</p>

</li>
<li><p>Provide links to further information (URL, email)</p>

</li>
</ul>

<h2 id="Release-considerations"><a class="permalink" href="perlmodstyle.html#Release-considerations">#</a><a id="Release"></a>Release considerations</h2>

<ul>

<li><p>Specify pre-requisites in Makefile.PL or Build.PL</p>

</li>
<li><p>Specify Perl version requirements with <code>use</code></p>

</li>
<li><p>Include tests with your module</p>

</li>
<li><p>Choose a sensible and consistent version numbering scheme (X.YY is the common Perl module numbering scheme)</p>

</li>
<li><p>Increment the version number for every change, no matter how small</p>

</li>
<li><p>Package the module using &quot;make dist&quot;</p>

</li>
<li><p>Choose an appropriate license (GPL/Artistic is a good default)</p>

</li>
</ul>

<h1 id="BEFORE-YOU-START-WRITING-A-MODULE"><a class="permalink" href="perlmodstyle.html#BEFORE-YOU-START-WRITING-A-MODULE">#</a><a id="BEFORE"></a>BEFORE YOU START WRITING A MODULE</h1>

<p>Try not to launch headlong into developing your module without spending some time thinking first. A little forethought may save you a vast amount of effort later on.</p>

<h2 id="Has-it-been-done-before?"><a class="permalink" href="perlmodstyle.html#Has-it-been-done-before?">#</a><a id="Has"></a><a id="Has-it-been-done-before"></a>Has it been done before?</h2>

<p>You may not even need to write the module. Check whether it&#39;s already been done in Perl, and avoid re-inventing the wheel unless you have a good reason.</p>

<p>Good places to look for pre-existing modules include <a href="https://metacpan.org">MetaCPAN</a> and <a href="http://prepan.org">PrePAN</a> and asking on <code>module-authors@perl.org</code> (<a href="https://lists.perl.org/list/module-authors.html">https://lists.perl.org/list/module-authors.html</a>).</p>

<p>If an existing module <b>almost</b> does what you want, consider writing a patch, writing a subclass, or otherwise extending the existing module rather than rewriting it.</p>

<h2 id="Do-one-thing-and-do-it-well"><a class="permalink" href="perlmodstyle.html#Do-one-thing-and-do-it-well">#</a><a id="Do"></a>Do one thing and do it well</h2>

<p>At the risk of stating the obvious, modules are intended to be modular. A Perl developer should be able to use modules to put together the building blocks of their application. However, it&#39;s important that the blocks are the right shape, and that the developer shouldn&#39;t have to use a big block when all they need is a small one.</p>

<p>Your module should have a clearly defined scope which is no longer than a single sentence. Can your module be broken down into a family of related modules?</p>

<p>Bad example:</p>

<p>&quot;FooBar.pm provides an implementation of the FOO protocol and the related BAR standard.&quot;</p>

<p>Good example:</p>

<p>&quot;Foo.pm provides an implementation of the FOO protocol. Bar.pm implements the related BAR protocol.&quot;</p>

<p>This means that if a developer only needs a module for the BAR standard, they should not be forced to install libraries for FOO as well.</p>

<h2 id="What&#39;s-in-a-name?"><a class="permalink" href="perlmodstyle.html#What&#39;s-in-a-name?">#</a><a id="What"></a><a id="Whats-in-a-name"></a>What&#39;s in a name?</h2>

<p>Make sure you choose an appropriate name for your module early on. This will help people find and remember your module, and make programming with your module more intuitive.</p>

<p>When naming your module, consider the following:</p>

<ul>

<li><p>Be descriptive (i.e. accurately describes the purpose of the module).</p>

</li>
<li><p>Be consistent with existing modules.</p>

</li>
<li><p>Reflect the functionality of the module, not the implementation.</p>

</li>
<li><p>Avoid starting a new top-level hierarchy, especially if a suitable hierarchy already exists under which you could place your module.</p>

</li>
</ul>

<h2 id="Get-feedback-before-publishing"><a class="permalink" href="perlmodstyle.html#Get-feedback-before-publishing">#</a><a id="Get"></a>Get feedback before publishing</h2>

<p>If you have never uploaded a module to CPAN before (and even if you have), you are strongly encouraged to get feedback on <a href="http://prepan.org">PrePAN</a>. PrePAN is a site dedicated to discussing ideas for CPAN modules with other Perl developers and is a great resource for new (and experienced) Perl developers.</p>

<p>You should also try to get feedback from people who are already familiar with the module&#39;s application domain and the CPAN naming system. Authors of similar modules, or modules with similar names, may be a good place to start, as are community sites like <a href="https://www.perlmonks.org">Perl Monks</a>.</p>

<h1 id="DESIGNING-AND-WRITING-YOUR-MODULE"><a class="permalink" href="perlmodstyle.html#DESIGNING-AND-WRITING-YOUR-MODULE">#</a><a id="DESIGNING"></a>DESIGNING AND WRITING YOUR MODULE</h1>

<p>Considerations for module design and coding:</p>

<h2 id="To-OO-or-not-to-OO?"><a class="permalink" href="perlmodstyle.html#To-OO-or-not-to-OO?">#</a><a id="To"></a><a id="To-OO-or-not-to-OO"></a>To OO or not to OO?</h2>

<p>Your module may be object oriented (OO) or not, or it may have both kinds of interfaces available. There are pros and cons of each technique, which should be considered when you design your API.</p>

<p>In <i>Perl Best Practices</i> (copyright 2004, Published by O&#39;Reilly Media, Inc.), Damian Conway provides a list of criteria to use when deciding if OO is the right fit for your problem:</p>

<ul>

<li><p>The system being designed is large, or is likely to become large.</p>

</li>
<li><p>The data can be aggregated into obvious structures, especially if there&#39;s a large amount of data in each aggregate.</p>

</li>
<li><p>The various types of data aggregate form a natural hierarchy that facilitates the use of inheritance and polymorphism.</p>

</li>
<li><p>You have a piece of data on which many different operations are applied.</p>

</li>
<li><p>You need to perform the same general operations on related types of data, but with slight variations depending on the specific type of data the operations are applied to.</p>

</li>
<li><p>It&#39;s likely you&#39;ll have to add new data types later.</p>

</li>
<li><p>The typical interactions between pieces of data are best represented by operators.</p>

</li>
<li><p>The implementation of individual components of the system is likely to change over time.</p>

</li>
<li><p>The system design is already object-oriented.</p>

</li>
<li><p>Large numbers of other programmers will be using your code modules.</p>

</li>
</ul>

<p>Think carefully about whether OO is appropriate for your module. Gratuitous object orientation results in complex APIs which are difficult for the average module user to understand or use.</p>

<h2 id="Designing-your-API"><a class="permalink" href="perlmodstyle.html#Designing-your-API">#</a><a id="Designing"></a>Designing your API</h2>

<p>Your interfaces should be understandable by an average Perl programmer. The following guidelines may help you judge whether your API is sufficiently straightforward:</p>

<dl>

<dt id="Write-simple-routines-to-do-simple-things."><a class="permalink" href="perlmodstyle.html#Write-simple-routines-to-do-simple-things.">#</a><a id="Write"></a><a id="Write-simple-routines-to-do-simple-things"></a>Write simple routines to do simple things.</dt>
<dd>

<p>It&#39;s better to have numerous simple routines than a few monolithic ones. If your routine changes its behaviour significantly based on its arguments, it&#39;s a sign that you should have two (or more) separate routines.</p>

</dd>
<dt id="Separate-functionality-from-output."><a class="permalink" href="perlmodstyle.html#Separate-functionality-from-output.">#</a><a id="Separate"></a><a id="Separate-functionality-from-output"></a>Separate functionality from output.</dt>
<dd>

<p>Return your results in the most generic form possible and allow the user to choose how to use them. The most generic form possible is usually a Perl data structure which can then be used to generate a text report, HTML, XML, a database query, or whatever else your users require.</p>

<p>If your routine iterates through some kind of list (such as a list of files, or records in a database) you may consider providing a callback so that users can manipulate each element of the list in turn. File::Find provides an example of this with its <code>find(\&amp;wanted, $dir)</code> syntax.</p>

</dd>
<dt id="Provide-sensible-shortcuts-and-defaults."><a class="permalink" href="perlmodstyle.html#Provide-sensible-shortcuts-and-defaults.">#</a><a id="Provide"></a><a id="Provide-sensible-shortcuts-and-defaults"></a>Provide sensible shortcuts and defaults.</dt>
<dd>

<p>Don&#39;t require every module user to jump through the same hoops to achieve a simple result. You can always include optional parameters or routines for more complex or non-standard behaviour. If most of your users have to type a few almost identical lines of code when they start using your module, it&#39;s a sign that you should have made that behaviour a default. Another good indicator that you should use defaults is if most of your users call your routines with the same arguments.</p>

</dd>
<dt id="Naming-conventions"><a class="permalink" href="perlmodstyle.html#Naming-conventions">#</a><a id="Naming"></a>Naming conventions</dt>
<dd>

<p>Your naming should be consistent. For instance, it&#39;s better to have:</p>

<pre><code>display_day();
display_week();
display_year();</code></pre>

<p>than</p>

<pre><code>display_day();
week_display();
show_year();</code></pre>

<p>This applies equally to method names, parameter names, and anything else which is visible to the user (and most things that aren&#39;t!)</p>

</dd>
<dt id="Parameter-passing"><a class="permalink" href="perlmodstyle.html#Parameter-passing">#</a><a id="Parameter"></a>Parameter passing</dt>
<dd>

<p>Use named parameters. It&#39;s easier to use a hash like this:</p>

<pre><code>    $obj-&gt;do_something(
	    name =&gt; &quot;wibble&quot;,
	    type =&gt; &quot;text&quot;,
	    size =&gt; 1024,
    );</code></pre>

<p>... than to have a long list of unnamed parameters like this:</p>

<pre><code>$obj-&gt;do_something(&quot;wibble&quot;, &quot;text&quot;, 1024);</code></pre>

<p>While the list of arguments might work fine for one, two or even three arguments, any more arguments become hard for the module user to remember, and hard for the module author to manage. If you want to add a new parameter you will have to add it to the end of the list for backward compatibility, and this will probably make your list order unintuitive. Also, if many elements may be undefined you may see the following unattractive method calls:</p>

<pre><code>$obj-&gt;do_something(undef, undef, undef, undef, undef, 1024);</code></pre>

<p>Provide sensible defaults for parameters which have them. Don&#39;t make your users specify parameters which will almost always be the same.</p>

<p>The issue of whether to pass the arguments in a hash or a hashref is largely a matter of personal style.</p>

<p>The use of hash keys starting with a hyphen (<code>-name</code>) or entirely in upper case (<code>NAME</code>) is a relic of older versions of Perl in which ordinary lower case strings were not handled correctly by the <code>=&gt;</code> operator. While some modules retain uppercase or hyphenated argument keys for historical reasons or as a matter of personal style, most new modules should use simple lower case keys. Whatever you choose, be consistent!</p>

</dd>
</dl>

<h2 id="Strictness-and-warnings"><a class="permalink" href="perlmodstyle.html#Strictness-and-warnings">#</a><a id="Strictness"></a>Strictness and warnings</h2>

<p>Your module should run successfully under the strict pragma and should run without generating any warnings. Your module should also handle taint-checking where appropriate, though this can cause difficulties in many cases.</p>

<h2 id="Backwards-compatibility"><a class="permalink" href="perlmodstyle.html#Backwards-compatibility">#</a><a id="Backwards"></a>Backwards compatibility</h2>

<p>Modules which are &quot;stable&quot; should not break backwards compatibility without at least a long transition phase and a major change in version number.</p>

<h2 id="Error-handling-and-messages"><a class="permalink" href="perlmodstyle.html#Error-handling-and-messages">#</a><a id="Error"></a>Error handling and messages</h2>

<p>When your module encounters an error it should do one or more of:</p>

<ul>

<li><p>Return an undefined value.</p>

</li>
<li><p>set <code>$Module::errstr</code> or similar (<code>errstr</code> is a common name used by DBI and other popular modules; if you choose something else, be sure to document it clearly).</p>

</li>
<li><p><code>warn()</code> or <code>carp()</code> a message to STDERR.</p>

</li>
<li><p><code>croak()</code> only when your module absolutely cannot figure out what to do. (<code>croak()</code> is a better version of <code>die()</code> for use within modules, which reports its errors from the perspective of the caller. See <a href="Carp.html">Carp</a> for details of <code>croak()</code>, <code>carp()</code> and other useful routines.)</p>

</li>
<li><p>As an alternative to the above, you may prefer to throw exceptions using the Error module.</p>

</li>
</ul>

<p>Configurable error handling can be very useful to your users. Consider offering a choice of levels for warning and debug messages, an option to send messages to a separate file, a way to specify an error-handling routine, or other such features. Be sure to default all these options to the commonest use.</p>

<h1 id="DOCUMENTING-YOUR-MODULE"><a class="permalink" href="perlmodstyle.html#DOCUMENTING-YOUR-MODULE">#</a><a id="DOCUMENTING"></a>DOCUMENTING YOUR MODULE</h1>

<h2 id="POD"><a class="permalink" href="perlmodstyle.html#POD">#</a>POD</h2>

<p>Your module should include documentation aimed at Perl developers. You should use Perl&#39;s &quot;plain old documentation&quot; (POD) for your general technical documentation, though you may wish to write additional documentation (white papers, tutorials, etc) in some other format. You need to cover the following subjects:</p>

<ul>

<li><p>A synopsis of the common uses of the module</p>

</li>
<li><p>The purpose, scope and target applications of your module</p>

</li>
<li><p>Use of each publicly accessible method or subroutine, including parameters and return values</p>

</li>
<li><p>Examples of use</p>

</li>
<li><p>Sources of further information</p>

</li>
<li><p>A contact email address for the author/maintainer</p>

</li>
</ul>

<p>The level of detail in Perl module documentation generally goes from less detailed to more detailed. Your SYNOPSIS section should contain a minimal example of use (perhaps as little as one line of code; skip the unusual use cases or anything not needed by most users); the DESCRIPTION should describe your module in broad terms, generally in just a few paragraphs; more detail of the module&#39;s routines or methods, lengthy code examples, or other in-depth material should be given in subsequent sections.</p>

<p>Ideally, someone who&#39;s slightly familiar with your module should be able to refresh their memory without hitting &quot;page down&quot;. As your reader continues through the document, they should receive a progressively greater amount of knowledge.</p>

<p>The recommended order of sections in Perl module documentation is:</p>

<ul>

<li><p>NAME</p>

</li>
<li><p>SYNOPSIS</p>

</li>
<li><p>DESCRIPTION</p>

</li>
<li><p>One or more sections or subsections giving greater detail of available methods and routines and any other relevant information.</p>

</li>
<li><p>BUGS/CAVEATS/etc</p>

</li>
<li><p>AUTHOR</p>

</li>
<li><p>SEE ALSO</p>

</li>
<li><p>COPYRIGHT and LICENSE</p>

</li>
</ul>

<p>Keep your documentation near the code it documents (&quot;inline&quot; documentation). Include POD for a given method right above that method&#39;s subroutine. This makes it easier to keep the documentation up to date, and avoids having to document each piece of code twice (once in POD and once in comments).</p>

<h2 id="README,-INSTALL,-release-notes,-changelogs"><a class="permalink" href="perlmodstyle.html#README,-INSTALL,-release-notes,-changelogs">#</a><a id="README"></a><a id="README-INSTALL-release-notes-changelogs"></a>README, INSTALL, release notes, changelogs</h2>

<p>Your module should also include a README file describing the module and giving pointers to further information (website, author email).</p>

<p>An INSTALL file should be included, and should contain simple installation instructions. When using ExtUtils::MakeMaker this will usually be:</p>

<dl>

<dt id="perl-Makefile.PL"><a class="permalink" href="perlmodstyle.html#perl-Makefile.PL">#</a><a id="perl"></a>perl Makefile.PL</dt>
<dd>

</dd>
<dt id="make"><a class="permalink" href="perlmodstyle.html#make">#</a>make</dt>
<dd>

</dd>
<dt id="make-test"><a class="permalink" href="perlmodstyle.html#make-test">#</a><a id="make1"></a>make test</dt>
<dd>

</dd>
<dt id="make-install"><a class="permalink" href="perlmodstyle.html#make-install">#</a><a id="make2"></a>make install</dt>
<dd>

</dd>
</dl>

<p>When using Module::Build, this will usually be:</p>

<dl>

<dt id="perl-Build.PL"><a class="permalink" href="perlmodstyle.html#perl-Build.PL">#</a><a id="perl1"></a>perl Build.PL</dt>
<dd>

</dd>
<dt id="perl-Build"><a class="permalink" href="perlmodstyle.html#perl-Build">#</a><a id="perl2"></a>perl Build</dt>
<dd>

</dd>
<dt id="perl-Build-test"><a class="permalink" href="perlmodstyle.html#perl-Build-test">#</a><a id="perl3"></a>perl Build test</dt>
<dd>

</dd>
<dt id="perl-Build-install"><a class="permalink" href="perlmodstyle.html#perl-Build-install">#</a><a id="perl4"></a>perl Build install</dt>
<dd>

</dd>
</dl>

<p>Release notes or changelogs should be produced for each release of your software describing user-visible changes to your module, in terms relevant to the user.</p>

<p>Unless you have good reasons for using some other format (for example, a format used within your company), the convention is to name your changelog file <code>Changes</code>, and to follow the simple format described in <a href="./CPAN::Changes::Spec.html">CPAN::Changes::Spec</a>.</p>

<h1 id="RELEASE-CONSIDERATIONS"><a class="permalink" href="perlmodstyle.html#RELEASE-CONSIDERATIONS">#</a><a id="RELEASE"></a>RELEASE CONSIDERATIONS</h1>

<h2 id="Version-numbering"><a class="permalink" href="perlmodstyle.html#Version-numbering">#</a><a id="Version"></a>Version numbering</h2>

<p>Version numbers should indicate at least major and minor releases, and possibly sub-minor releases. A major release is one in which most of the functionality has changed, or in which major new functionality is added. A minor release is one in which a small amount of functionality has been added or changed. Sub-minor version numbers are usually used for changes which do not affect functionality, such as documentation patches.</p>

<p>The most common CPAN version numbering scheme looks like this:</p>

<pre><code class="plaintext">1.00, 1.10, 1.11, 1.20, 1.30, 1.31, 1.32</code></pre>

<p>A correct CPAN version number is a floating point number with at least 2 digits after the decimal. You can test whether it conforms to CPAN by using</p>

<pre><code>perl -MExtUtils::MakeMaker -le &#39;print MM-&gt;parse_version(shift)&#39; \
                                                        &#39;Foo.pm&#39;</code></pre>

<p>If you want to release a &#39;beta&#39; or &#39;alpha&#39; version of a module but don&#39;t want CPAN.pm to list it as most recent use an &#39;_&#39; after the regular version number followed by at least 2 digits, eg. 1.20_01. If you do this, the following idiom is recommended:</p>

<pre><code>our $VERSION = &quot;1.12_01&quot;; # so CPAN distribution will have
                          # right filename
our $XS_VERSION = $VERSION; # only needed if you have XS code
$VERSION = eval $VERSION; # so &quot;use Module 0.002&quot; won&#39;t warn on
                          # underscore</code></pre>

<p>With that trick MakeMaker will only read the first line and thus read the underscore, while the perl interpreter will evaluate the $VERSION and convert the string into a number. Later operations that treat $VERSION as a number will then be able to do so without provoking a warning about $VERSION not being a number.</p>

<p>Never release anything (even a one-word documentation patch) without incrementing the number. Even a one-word documentation patch should result in a change in version at the sub-minor level.</p>

<p>Once picked, it is important to stick to your version scheme, without reducing the number of digits. This is because &quot;downstream&quot; packagers, such as the FreeBSD ports system, interpret the version numbers in various ways. If you change the number of digits in your version scheme, you can confuse these systems so they get the versions of your module out of order, which is obviously bad.</p>

<h2 id="Pre-requisites"><a class="permalink" href="perlmodstyle.html#Pre-requisites">#</a><a id="Pre"></a>Pre-requisites</h2>

<p>Module authors should carefully consider whether to rely on other modules, and which modules to rely on.</p>

<p>Most importantly, choose modules which are as stable as possible. In order of preference:</p>

<ul>

<li><p>Core Perl modules</p>

</li>
<li><p>Stable CPAN modules</p>

</li>
<li><p>Unstable CPAN modules</p>

</li>
<li><p>Modules not available from CPAN</p>

</li>
</ul>

<p>Specify version requirements for other Perl modules in the pre-requisites in your Makefile.PL or Build.PL.</p>

<p>Be sure to specify Perl version requirements both in Makefile.PL or Build.PL and with <code>require 5.6.1</code> or similar. See the section on <code>use VERSION</code> of <a href="perlfunc.html#require">&quot;require&quot; in perlfunc</a> for details.</p>

<h2 id="Testing"><a class="permalink" href="perlmodstyle.html#Testing">#</a>Testing</h2>

<p>All modules should be tested before distribution (using &quot;make disttest&quot;), and the tests should also be available to people installing the modules (using &quot;make test&quot;). For Module::Build you would use the <code>make test</code> equivalent <code>perl Build test</code>.</p>

<p>The importance of these tests is proportional to the alleged stability of a module. A module which purports to be stable or which hopes to achieve wide use should adhere to as strict a testing regime as possible.</p>

<p>Useful modules to help you write tests (with minimum impact on your development process or your time) include Test::Simple, Carp::Assert and Test::Inline. For more sophisticated test suites there are Test::More and Test::MockObject.</p>

<h2 id="Packaging"><a class="permalink" href="perlmodstyle.html#Packaging">#</a>Packaging</h2>

<p>Modules should be packaged using one of the standard packaging tools. Currently you have the choice between ExtUtils::MakeMaker and the more platform independent Module::Build, allowing modules to be installed in a consistent manner. When using ExtUtils::MakeMaker, you can use &quot;make dist&quot; to create your package. Tools exist to help you to build your module in a MakeMaker-friendly style. These include ExtUtils::ModuleMaker and h2xs. See also <a href="perlnewmod.html">perlnewmod</a>.</p>

<h2 id="Licensing"><a class="permalink" href="perlmodstyle.html#Licensing">#</a>Licensing</h2>

<p>Make sure that your module has a license, and that the full text of it is included in the distribution (unless it&#39;s a common one and the terms of the license don&#39;t require you to include it).</p>

<p>If you don&#39;t know what license to use, dual licensing under the GPL and Artistic licenses (the same as Perl itself) is a good idea. See <a href="perlgpl.html">perlgpl</a> and <a href="perlartistic.html">perlartistic</a>.</p>

<h1 id="COMMON-PITFALLS"><a class="permalink" href="perlmodstyle.html#COMMON-PITFALLS">#</a><a id="COMMON"></a>COMMON PITFALLS</h1>

<h2 id="Reinventing-the-wheel"><a class="permalink" href="perlmodstyle.html#Reinventing-the-wheel">#</a><a id="Reinventing"></a>Reinventing the wheel</h2>

<p>There are certain application spaces which are already very, very well served by CPAN. One example is templating systems, another is date and time modules, and there are many more. While it is a rite of passage to write your own version of these things, please consider carefully whether the Perl world really needs you to publish it.</p>

<h2 id="Trying-to-do-too-much"><a class="permalink" href="perlmodstyle.html#Trying-to-do-too-much">#</a><a id="Trying"></a>Trying to do too much</h2>

<p>Your module will be part of a developer&#39;s toolkit. It will not, in itself, form the <b>entire</b> toolkit. It&#39;s tempting to add extra features until your code is a monolithic system rather than a set of modular building blocks.</p>

<h2 id="Inappropriate-documentation"><a class="permalink" href="perlmodstyle.html#Inappropriate-documentation">#</a><a id="Inappropriate"></a>Inappropriate documentation</h2>

<p>Don&#39;t fall into the trap of writing for the wrong audience. Your primary audience is a reasonably experienced developer with at least a moderate understanding of your module&#39;s application domain, who&#39;s just downloaded your module and wants to start using it as quickly as possible.</p>

<p>Tutorials, end-user documentation, research papers, FAQs etc are not appropriate in a module&#39;s main documentation. If you really want to write these, include them as sub-documents such as <code>My::Module::Tutorial</code> or <code>My::Module::FAQ</code> and provide a link in the SEE ALSO section of the main documentation.</p>

<h1 id="SEE-ALSO"><a class="permalink" href="perlmodstyle.html#SEE-ALSO">#</a><a id="SEE"></a>SEE ALSO</h1>

<dl>

<dt id="perlstyle"><a class="permalink" href="perlmodstyle.html#perlstyle">#</a><a href="perlstyle.html">perlstyle</a></dt>
<dd>

<p>General Perl style guide</p>

</dd>
<dt id="perlnewmod"><a class="permalink" href="perlmodstyle.html#perlnewmod">#</a><a href="perlnewmod.html">perlnewmod</a></dt>
<dd>

<p>How to create a new module</p>

</dd>
<dt id="perlpod"><a class="permalink" href="perlmodstyle.html#perlpod">#</a><a href="perlpod.html">perlpod</a></dt>
<dd>

<p>POD documentation</p>

</dd>
<dt id="podchecker"><a class="permalink" href="perlmodstyle.html#podchecker">#</a><a href="podchecker.html">podchecker</a></dt>
<dd>

<p>Verifies your POD&#39;s correctness</p>

</dd>
<dt id="Packaging-Tools"><a class="permalink" href="perlmodstyle.html#Packaging-Tools">#</a><a id="Packaging1"></a>Packaging Tools</dt>
<dd>

<p><a href="./ExtUtils::MakeMaker.html">ExtUtils::MakeMaker</a>, <a href="./Module::Build.html">Module::Build</a></p>

</dd>
<dt id="Testing-tools"><a class="permalink" href="perlmodstyle.html#Testing-tools">#</a><a id="Testing1"></a>Testing tools</dt>
<dd>

<p><a href="./Test::Simple.html">Test::Simple</a>, <a href="./Test::Inline.html">Test::Inline</a>, <a href="./Carp::Assert.html">Carp::Assert</a>, <a href="./Test::More.html">Test::More</a>, <a href="./Test::MockObject.html">Test::MockObject</a></p>

</dd>
<dt id="https://pause.perl.org/"><a class="permalink" href="perlmodstyle.html#https://pause.perl.org/">#</a><a id="https"></a><a id="https:-pause.perl.org"></a><a href="https://pause.perl.org/">https://pause.perl.org/</a></dt>
<dd>

<p>Perl Authors Upload Server. Contains links to information for module authors.</p>

</dd>
<dt id="Any-good-book-on-software-engineering"><a class="permalink" href="perlmodstyle.html#Any-good-book-on-software-engineering">#</a><a id="Any"></a>Any good book on software engineering</dt>
<dd>

</dd>
</dl>

<h1 id="AUTHOR"><a class="permalink" href="perlmodstyle.html#AUTHOR">#</a>AUTHOR</h1>

<p>Kirrily &quot;Skud&quot; Robert &lt;skud@cpan.org&gt;</p>


      </div>
      <div id="footer">
        <p>Perldoc Browser is maintained by Dan Book (<a href="https://metacpan.org/author/DBOOK">DBOOK</a>). Please contact him via the <a href="https://github.com/Grinnz/perldoc-browser/issues">GitHub issue tracker</a> or <a href="mailto:dbook@cpan.org">email</a> regarding any issues with the site itself, search, or rendering of documentation.</p>

<p>The Perl documentation is maintained by the Perl 5 Porters in the development of Perl. Please contact them via the <a href="https://github.com/Perl/perl5/issues">Perl issue tracker</a>, the <a href="https://lists.perl.org/list/perl5-porters.html">mailing list</a>, or <a href="https://kiwiirc.com/client/irc.perl.org/p5p">IRC</a> to report any issues with the contents or format of the documentation.</p>


      </div>
    </div>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.slim.min.js" integrity="sha512-/DXTXr6nQodMUiq+IUJYCt2PPOUjrHJ9wFrqpJ3XkgPNOZVfMok7cRw6CSxyCQxXn6ozlESsSh1/sMCTF1rL/g==" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.1/umd/popper.min.js" integrity="sha512-ubuT8Z88WxezgSqf3RLuNi5lmjstiJcyezx34yIU2gAHonIi27Na7atqzUZCOoY4CExaoFumzOsFQ2Ch+I/HCw==" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous"></script>
    <script src="../highlight.pack.js"></script>
    <script>hljs.highlightAll();</script>
  </body>
</html>
